package com.droowa.model.dao;

import java.sql.SQLException;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.droowa.domain.DeliveryOption;

@Repository
public class DeliveryOptionDAOMybatisImpl implements DeliveryOptionDAO{

	@Autowired
	private SqlSessionTemplate session;
	
	@Override
	public int insertDeliveryOption(DeliveryOption deliveryOption)
			throws SQLException {
		return session.insert(makeSqlId("insertDeliveryOption"), deliveryOption);
	}

	@Override
	public int deleteDeliveryOption() throws SQLException {
		return session.delete(makeSqlId("deleteDeliveryOption"));
	}

	@Override
	public int updateDeliveryOption(DeliveryOption deliveryOption)
			throws SQLException {
		return session.update(makeSqlId("updateDeliveryOption"), deliveryOption);
	}

	@Override
	public DeliveryOption selectDeliveryOption() throws SQLException {
		return session.selectOne(makeSqlId("selectDeliveryOption"));
	}

	private String makeSqlId(String id){
		return "droowa.DeliveryOption."+id;
	}
}
